Skip to content

Scheduler: Provide the SnapToCellsMode option#33021

Open
sjbur wants to merge 12 commits intoDevExpress:26_1from
sjbur:v2_issue-3654_26_1
Open

Scheduler: Provide the SnapToCellsMode option#33021
sjbur wants to merge 12 commits intoDevExpress:26_1from
sjbur:v2_issue-3654_26_1

Conversation

@sjbur
Copy link
Contributor

@sjbur sjbur commented Mar 24, 2026

No description provided.

@sjbur sjbur self-assigned this Mar 24, 2026
@sjbur sjbur added the 26_1 label Mar 24, 2026
@sjbur sjbur changed the title V2 issue 3654 26 1 Scheduler: Provide the SnapToCellsMode option Mar 24, 2026
@sjbur sjbur force-pushed the v2_issue-3654_26_1 branch 2 times, most recently from b489e98 to 0e91e46 Compare March 24, 2026 10:44
@sjbur sjbur force-pushed the v2_issue-3654_26_1 branch from 0e91e46 to 21d39d2 Compare March 24, 2026 10:45
@sjbur sjbur marked this pull request as ready for review March 24, 2026 11:13
@sjbur sjbur requested a review from a team as a code owner March 24, 2026 11:13
@sjbur sjbur force-pushed the v2_issue-3654_26_1 branch from 21d39d2 to 7263bf7 Compare March 24, 2026 12:25
export type GroupOrientation = 'vertical' | 'horizontal';
export type ViewType = 'agenda' | 'day' | 'month' | 'timelineDay' | 'timelineMonth' | 'timelineWeek' | 'timelineWorkWeek' | 'week' | 'workWeek';
export type AllDayPanelModeType = 'all' | 'allDay' | 'hidden';
export type SnapToCellsModeType = 'always' | 'auto' | 'never';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestion: we can import this type directly from Scheduler's d.ts (like Appointment type is imported), instead of duplicating the type here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

isTimelineView: true, isMonthView: true, viewOrientation: 'horizontal', snapToCellsMode: 'always',
},
agenda: {
isTimelineView: false, isMonthView: false, viewOrientation: 'vertical', snapToCellsMode: 'always',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: can we remove 'agenda' view from this config as it was before? Agenda view doesn't have snapping at all, and so agenda.snapToCellsMode value will never be read.

Copy link
Contributor

@Tucchhaa Tucchhaa Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I see in the generateViewModel function here, when generating view model for agenda, the option manager is never used. So we really don't need value for 'agenda' here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

timelineWeek: { isTimelineView: true, isMonthView: false, viewOrientation: 'horizontal' },
timelineWorkWeek: { isTimelineView: true, isMonthView: false, viewOrientation: 'horizontal' },
timelineMonth: { isTimelineView: true, isMonthView: true, viewOrientation: 'horizontal' },
snapToCellsMode: SnapToCellsModeType;
Copy link
Contributor

@Tucchhaa Tucchhaa Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to move default snapToCellsMode values to contant_view.ts.

That file already defines specific default options for each view.

If you move default values there, then we won't need to get defaultSnapToCellsMode here, because schedulerStore.getViewOption('snapToCellsMode') will be enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried putting the default in constants_view.ts, but that merges into each view object, so getViewOption('snapToCellsMode') always sees a value on the view and never falls back to the root option. So defaults for snapToCellsMode can’t live in DEFAULT_VIEW_OPTIONS the same way as other view fields if we want root-level snapToCellsMode to work.

innerStep2,
optionManager.getCells(panelName),
panelName === 'allDayPanel' ? 'always' : snapToCellsMode,
);
Copy link
Contributor

@Tucchhaa Tucchhaa Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add tests that check that scheduler.snapToCellsMode and scheduler.view.snapToCellsMode options actually have effect?

I mean if I have this config:

$().dxScheduler({
   snapToCellsMode: 'always',
   currentView: 'day'
})

or this config:

$().dxScheduler({
   view: [{ type: 'day', snapToCells: 'always' }]
   currentView: 'day'
})

then check that the option is applied

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added integration test which tests 3 cases for day view

  1. Checks default behaviour without setting snapToCellsMode
  2. Checks behaviour when root snapToCellsMode is set
  3. Checks behaviour when snapToCellsMode is set via views config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants